// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.

#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]
#![no_implicit_prelude]
extern crate async_trait;
extern crate bytes;
extern crate gax;
extern crate gaxi;
extern crate iam_v1;
extern crate lazy_static;
extern crate location;
extern crate longrunning;
extern crate lro;
extern crate reqwest;
extern crate serde;
extern crate serde_json;
extern crate serde_with;
extern crate std;
extern crate tracing;
extern crate wkt;

mod debug;
mod deserialize;
mod serialize;

/// AppConnectorInstanceConfig defines the instance config of a AppConnector.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct AppConnectorInstanceConfig {
    /// Required. A monotonically increasing number generated and maintained
    /// by the API provider. Every time a config changes in the backend, the
    /// sequenceNumber should be bumped up to reflect the change.
    pub sequence_number: i64,

    /// The SLM instance agent configuration.
    pub instance_config: std::option::Option<wkt::Any>,

    /// NotificationConfig defines the notification mechanism that the remote
    /// instance should subscribe to in order to receive notification.
    pub notification_config: std::option::Option<crate::model::NotificationConfig>,

    /// ImageConfig defines the GCR images to run for the remote agent's control
    /// plane.
    pub image_config: std::option::Option<crate::model::ImageConfig>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl AppConnectorInstanceConfig {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [sequence_number][crate::model::AppConnectorInstanceConfig::sequence_number].
    pub fn set_sequence_number<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
        self.sequence_number = v.into();
        self
    }

    /// Sets the value of [instance_config][crate::model::AppConnectorInstanceConfig::instance_config].
    pub fn set_instance_config<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Any>,
    {
        self.instance_config = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [instance_config][crate::model::AppConnectorInstanceConfig::instance_config].
    pub fn set_or_clear_instance_config<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Any>,
    {
        self.instance_config = v.map(|x| x.into());
        self
    }

    /// Sets the value of [notification_config][crate::model::AppConnectorInstanceConfig::notification_config].
    pub fn set_notification_config<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::NotificationConfig>,
    {
        self.notification_config = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [notification_config][crate::model::AppConnectorInstanceConfig::notification_config].
    pub fn set_or_clear_notification_config<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::NotificationConfig>,
    {
        self.notification_config = v.map(|x| x.into());
        self
    }

    /// Sets the value of [image_config][crate::model::AppConnectorInstanceConfig::image_config].
    pub fn set_image_config<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::ImageConfig>,
    {
        self.image_config = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [image_config][crate::model::AppConnectorInstanceConfig::image_config].
    pub fn set_or_clear_image_config<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::ImageConfig>,
    {
        self.image_config = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for AppConnectorInstanceConfig {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.beyondcorp.appconnectors.v1.AppConnectorInstanceConfig"
    }
}

/// NotificationConfig defines the mechanisms to notify instance agent.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct NotificationConfig {
    pub config: std::option::Option<crate::model::notification_config::Config>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl NotificationConfig {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [config][crate::model::NotificationConfig::config].
    ///
    /// Note that all the setters affecting `config` are mutually
    /// exclusive.
    pub fn set_config<
        T: std::convert::Into<std::option::Option<crate::model::notification_config::Config>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.config = v.into();
        self
    }

    /// The value of [config][crate::model::NotificationConfig::config]
    /// if it holds a `PubsubNotification`, `None` if the field is not set or
    /// holds a different branch.
    pub fn pubsub_notification(
        &self,
    ) -> std::option::Option<
        &std::boxed::Box<crate::model::notification_config::CloudPubSubNotificationConfig>,
    > {
        #[allow(unreachable_patterns)]
        self.config.as_ref().and_then(|v| match v {
            crate::model::notification_config::Config::PubsubNotification(v) => {
                std::option::Option::Some(v)
            }
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [config][crate::model::NotificationConfig::config]
    /// to hold a `PubsubNotification`.
    ///
    /// Note that all the setters affecting `config` are
    /// mutually exclusive.
    pub fn set_pubsub_notification<
        T: std::convert::Into<
                std::boxed::Box<crate::model::notification_config::CloudPubSubNotificationConfig>,
            >,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.config = std::option::Option::Some(
            crate::model::notification_config::Config::PubsubNotification(v.into()),
        );
        self
    }
}

impl wkt::message::Message for NotificationConfig {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.beyondcorp.appconnectors.v1.NotificationConfig"
    }
}

/// Defines additional types related to [NotificationConfig].
pub mod notification_config {
    #[allow(unused_imports)]
    use super::*;

    /// The configuration for Pub/Sub messaging for the AppConnector.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct CloudPubSubNotificationConfig {
        /// The Pub/Sub subscription the AppConnector uses to receive notifications.
        pub pubsub_subscription: std::string::String,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl CloudPubSubNotificationConfig {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [pubsub_subscription][crate::model::notification_config::CloudPubSubNotificationConfig::pubsub_subscription].
        pub fn set_pubsub_subscription<T: std::convert::Into<std::string::String>>(
            mut self,
            v: T,
        ) -> Self {
            self.pubsub_subscription = v.into();
            self
        }
    }

    impl wkt::message::Message for CloudPubSubNotificationConfig {
        fn typename() -> &'static str {
            "type.googleapis.com/google.cloud.beyondcorp.appconnectors.v1.NotificationConfig.CloudPubSubNotificationConfig"
        }
    }

    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum Config {
        /// Cloud Pub/Sub Configuration to receive notifications.
        PubsubNotification(
            std::boxed::Box<crate::model::notification_config::CloudPubSubNotificationConfig>,
        ),
    }
}

/// ImageConfig defines the control plane images to run.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ImageConfig {
    /// The initial image the remote agent will attempt to run for the control
    /// plane.
    pub target_image: std::string::String,

    /// The stable image that the remote agent will fallback to if the target image
    /// fails.
    pub stable_image: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ImageConfig {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [target_image][crate::model::ImageConfig::target_image].
    pub fn set_target_image<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.target_image = v.into();
        self
    }

    /// Sets the value of [stable_image][crate::model::ImageConfig::stable_image].
    pub fn set_stable_image<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.stable_image = v.into();
        self
    }
}

impl wkt::message::Message for ImageConfig {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.beyondcorp.appconnectors.v1.ImageConfig"
    }
}

/// Request message for BeyondCorp.ListAppConnectors.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListAppConnectorsRequest {
    /// Required. The resource name of the AppConnector location using the form:
    /// `projects/{project_id}/locations/{location_id}`
    pub parent: std::string::String,

    /// Optional. The maximum number of items to return.
    /// If not specified, a default value of 50 will be used by the service.
    /// Regardless of the page_size value, the response may include a partial list
    /// and a caller should only rely on response's
    /// [next_page_token][BeyondCorp.ListAppConnectorsResponse.next_page_token] to
    /// determine if there are more instances left to be queried.
    pub page_size: i32,

    /// Optional. The next_page_token value returned from a previous
    /// ListAppConnectorsRequest, if any.
    pub page_token: std::string::String,

    /// Optional. A filter specifying constraints of a list operation.
    pub filter: std::string::String,

    /// Optional. Specifies the ordering of results. See
    /// [Sorting
    /// order](https://cloud.google.com/apis/design/design_patterns#sorting_order)
    /// for more information.
    pub order_by: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListAppConnectorsRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::ListAppConnectorsRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [page_size][crate::model::ListAppConnectorsRequest::page_size].
    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.page_size = v.into();
        self
    }

    /// Sets the value of [page_token][crate::model::ListAppConnectorsRequest::page_token].
    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.page_token = v.into();
        self
    }

    /// Sets the value of [filter][crate::model::ListAppConnectorsRequest::filter].
    pub fn set_filter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.filter = v.into();
        self
    }

    /// Sets the value of [order_by][crate::model::ListAppConnectorsRequest::order_by].
    pub fn set_order_by<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.order_by = v.into();
        self
    }
}

impl wkt::message::Message for ListAppConnectorsRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.beyondcorp.appconnectors.v1.ListAppConnectorsRequest"
    }
}

/// Response message for BeyondCorp.ListAppConnectors.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListAppConnectorsResponse {
    /// A list of BeyondCorp AppConnectors in the project.
    pub app_connectors: std::vec::Vec<crate::model::AppConnector>,

    /// A token to retrieve the next page of results, or empty if there are no more
    /// results in the list.
    pub next_page_token: std::string::String,

    /// A list of locations that could not be reached.
    pub unreachable: std::vec::Vec<std::string::String>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListAppConnectorsResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [app_connectors][crate::model::ListAppConnectorsResponse::app_connectors].
    pub fn set_app_connectors<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::AppConnector>,
    {
        use std::iter::Iterator;
        self.app_connectors = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [next_page_token][crate::model::ListAppConnectorsResponse::next_page_token].
    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.next_page_token = v.into();
        self
    }

    /// Sets the value of [unreachable][crate::model::ListAppConnectorsResponse::unreachable].
    pub fn set_unreachable<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.unreachable = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for ListAppConnectorsResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.beyondcorp.appconnectors.v1.ListAppConnectorsResponse"
    }
}

#[doc(hidden)]
impl gax::paginator::internal::PageableResponse for ListAppConnectorsResponse {
    type PageItem = crate::model::AppConnector;

    fn items(self) -> std::vec::Vec<Self::PageItem> {
        self.app_connectors
    }

    fn next_page_token(&self) -> std::string::String {
        use std::clone::Clone;
        self.next_page_token.clone()
    }
}

/// Request message for BeyondCorp.GetAppConnector.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct GetAppConnectorRequest {
    /// Required. BeyondCorp AppConnector name using the form:
    /// `projects/{project_id}/locations/{location_id}/appConnectors/{app_connector_id}`
    pub name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl GetAppConnectorRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::GetAppConnectorRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }
}

impl wkt::message::Message for GetAppConnectorRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.beyondcorp.appconnectors.v1.GetAppConnectorRequest"
    }
}

/// Request message for BeyondCorp.CreateAppConnector.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CreateAppConnectorRequest {
    /// Required. The resource project name of the AppConnector location using the
    /// form: `projects/{project_id}/locations/{location_id}`
    pub parent: std::string::String,

    /// Optional. User-settable AppConnector resource ID.
    ///
    /// * Must start with a letter.
    /// * Must contain between 4-63 characters from `/[a-z][0-9]-/`.
    /// * Must end with a number or a letter.
    pub app_connector_id: std::string::String,

    /// Required. A BeyondCorp AppConnector resource.
    pub app_connector: std::option::Option<crate::model::AppConnector>,

    /// Optional. An optional request ID to identify requests. Specify a unique
    /// request ID so that if you must retry your request, the server will know to
    /// ignore the request if it has already been completed. The server will
    /// guarantee that for at least 60 minutes since the first request.
    ///
    /// For example, consider a situation where you make an initial request and t
    /// he request times out. If you make the request again with the same request
    /// ID, the server can check if original operation with the same request ID
    /// was received, and if so, will ignore the second request. This prevents
    /// clients from accidentally creating duplicate commitments.
    ///
    /// The request ID must be a valid UUID with the exception that zero UUID is
    /// not supported (00000000-0000-0000-0000-000000000000).
    pub request_id: std::string::String,

    /// Optional. If set, validates request by executing a dry-run which would not
    /// alter the resource in any way.
    pub validate_only: bool,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl CreateAppConnectorRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::CreateAppConnectorRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [app_connector_id][crate::model::CreateAppConnectorRequest::app_connector_id].
    pub fn set_app_connector_id<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.app_connector_id = v.into();
        self
    }

    /// Sets the value of [app_connector][crate::model::CreateAppConnectorRequest::app_connector].
    pub fn set_app_connector<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::AppConnector>,
    {
        self.app_connector = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [app_connector][crate::model::CreateAppConnectorRequest::app_connector].
    pub fn set_or_clear_app_connector<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::AppConnector>,
    {
        self.app_connector = v.map(|x| x.into());
        self
    }

    /// Sets the value of [request_id][crate::model::CreateAppConnectorRequest::request_id].
    pub fn set_request_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.request_id = v.into();
        self
    }

    /// Sets the value of [validate_only][crate::model::CreateAppConnectorRequest::validate_only].
    pub fn set_validate_only<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.validate_only = v.into();
        self
    }
}

impl wkt::message::Message for CreateAppConnectorRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.beyondcorp.appconnectors.v1.CreateAppConnectorRequest"
    }
}

/// Request message for BeyondCorp.UpdateAppConnector.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct UpdateAppConnectorRequest {
    /// Required. Mask of fields to update. At least one path must be supplied in
    /// this field. The elements of the repeated paths field may only include these
    /// fields from [BeyondCorp.AppConnector]:
    ///
    /// * `labels`
    /// * `display_name`
    pub update_mask: std::option::Option<wkt::FieldMask>,

    /// Required. AppConnector message with updated fields. Only supported fields
    /// specified in update_mask are updated.
    pub app_connector: std::option::Option<crate::model::AppConnector>,

    /// Optional. An optional request ID to identify requests. Specify a unique
    /// request ID so that if you must retry your request, the server will know to
    /// ignore the request if it has already been completed. The server will
    /// guarantee that for at least 60 minutes since the first request.
    ///
    /// For example, consider a situation where you make an initial request and t
    /// he request times out. If you make the request again with the same request
    /// ID, the server can check if original operation with the same request ID
    /// was received, and if so, will ignore the second request. This prevents
    /// clients from accidentally creating duplicate commitments.
    ///
    /// The request ID must be a valid UUID with the exception that zero UUID is
    /// not supported (00000000-0000-0000-0000-000000000000).
    pub request_id: std::string::String,

    /// Optional. If set, validates request by executing a dry-run which would not
    /// alter the resource in any way.
    pub validate_only: bool,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl UpdateAppConnectorRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [update_mask][crate::model::UpdateAppConnectorRequest::update_mask].
    pub fn set_update_mask<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::FieldMask>,
    {
        self.update_mask = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [update_mask][crate::model::UpdateAppConnectorRequest::update_mask].
    pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::FieldMask>,
    {
        self.update_mask = v.map(|x| x.into());
        self
    }

    /// Sets the value of [app_connector][crate::model::UpdateAppConnectorRequest::app_connector].
    pub fn set_app_connector<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::AppConnector>,
    {
        self.app_connector = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [app_connector][crate::model::UpdateAppConnectorRequest::app_connector].
    pub fn set_or_clear_app_connector<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::AppConnector>,
    {
        self.app_connector = v.map(|x| x.into());
        self
    }

    /// Sets the value of [request_id][crate::model::UpdateAppConnectorRequest::request_id].
    pub fn set_request_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.request_id = v.into();
        self
    }

    /// Sets the value of [validate_only][crate::model::UpdateAppConnectorRequest::validate_only].
    pub fn set_validate_only<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.validate_only = v.into();
        self
    }
}

impl wkt::message::Message for UpdateAppConnectorRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.beyondcorp.appconnectors.v1.UpdateAppConnectorRequest"
    }
}

/// Request message for BeyondCorp.DeleteAppConnector.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct DeleteAppConnectorRequest {
    /// Required. BeyondCorp AppConnector name using the form:
    /// `projects/{project_id}/locations/{location_id}/appConnectors/{app_connector_id}`
    pub name: std::string::String,

    /// Optional. An optional request ID to identify requests. Specify a unique
    /// request ID so that if you must retry your request, the server will know to
    /// ignore the request if it has already been completed. The server will
    /// guarantee that for at least 60 minutes after the first request.
    ///
    /// For example, consider a situation where you make an initial request and t
    /// he request times out. If you make the request again with the same request
    /// ID, the server can check if original operation with the same request ID
    /// was received, and if so, will ignore the second request. This prevents
    /// clients from accidentally creating duplicate commitments.
    ///
    /// The request ID must be a valid UUID with the exception that zero UUID is
    /// not supported (00000000-0000-0000-0000-000000000000).
    pub request_id: std::string::String,

    /// Optional. If set, validates request by executing a dry-run which would not
    /// alter the resource in any way.
    pub validate_only: bool,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl DeleteAppConnectorRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::DeleteAppConnectorRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [request_id][crate::model::DeleteAppConnectorRequest::request_id].
    pub fn set_request_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.request_id = v.into();
        self
    }

    /// Sets the value of [validate_only][crate::model::DeleteAppConnectorRequest::validate_only].
    pub fn set_validate_only<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.validate_only = v.into();
        self
    }
}

impl wkt::message::Message for DeleteAppConnectorRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.beyondcorp.appconnectors.v1.DeleteAppConnectorRequest"
    }
}

/// Request report the connector status.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ReportStatusRequest {
    /// Required. BeyondCorp Connector name using the form:
    /// `projects/{project_id}/locations/{location_id}/connectors/{connector}`
    pub app_connector: std::string::String,

    /// Required. Resource info of the connector.
    pub resource_info: std::option::Option<crate::model::ResourceInfo>,

    /// Optional. An optional request ID to identify requests. Specify a unique
    /// request ID so that if you must retry your request, the server will know to
    /// ignore the request if it has already been completed. The server will
    /// guarantee that for at least 60 minutes since the first request.
    ///
    /// For example, consider a situation where you make an initial request and t
    /// he request times out. If you make the request again with the same request
    /// ID, the server can check if original operation with the same request ID
    /// was received, and if so, will ignore the second request. This prevents
    /// clients from accidentally creating duplicate commitments.
    ///
    /// The request ID must be a valid UUID with the exception that zero UUID is
    /// not supported (00000000-0000-0000-0000-000000000000).
    pub request_id: std::string::String,

    /// Optional. If set, validates request by executing a dry-run which would not
    /// alter the resource in any way.
    pub validate_only: bool,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ReportStatusRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [app_connector][crate::model::ReportStatusRequest::app_connector].
    pub fn set_app_connector<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.app_connector = v.into();
        self
    }

    /// Sets the value of [resource_info][crate::model::ReportStatusRequest::resource_info].
    pub fn set_resource_info<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::ResourceInfo>,
    {
        self.resource_info = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [resource_info][crate::model::ReportStatusRequest::resource_info].
    pub fn set_or_clear_resource_info<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::ResourceInfo>,
    {
        self.resource_info = v.map(|x| x.into());
        self
    }

    /// Sets the value of [request_id][crate::model::ReportStatusRequest::request_id].
    pub fn set_request_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.request_id = v.into();
        self
    }

    /// Sets the value of [validate_only][crate::model::ReportStatusRequest::validate_only].
    pub fn set_validate_only<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.validate_only = v.into();
        self
    }
}

impl wkt::message::Message for ReportStatusRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.beyondcorp.appconnectors.v1.ReportStatusRequest"
    }
}

/// A BeyondCorp connector resource that represents an application facing
/// component deployed proximal to and with direct access to the application
/// instances. It is used to establish connectivity between the remote enterprise
/// environment and GCP. It initiates connections to the applications and can
/// proxy the data from users over the connection.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct AppConnector {
    /// Required. Unique resource name of the AppConnector.
    /// The name is ignored when creating a AppConnector.
    pub name: std::string::String,

    /// Output only. Timestamp when the resource was created.
    pub create_time: std::option::Option<wkt::Timestamp>,

    /// Output only. Timestamp when the resource was last modified.
    pub update_time: std::option::Option<wkt::Timestamp>,

    /// Optional. Resource labels to represent user provided metadata.
    pub labels: std::collections::HashMap<std::string::String, std::string::String>,

    /// Optional. An arbitrary user-provided name for the AppConnector. Cannot
    /// exceed 64 characters.
    pub display_name: std::string::String,

    /// Output only. A unique identifier for the instance generated by the
    /// system.
    pub uid: std::string::String,

    /// Output only. The current state of the AppConnector.
    pub state: crate::model::app_connector::State,

    /// Required. Principal information about the Identity of the AppConnector.
    pub principal_info: std::option::Option<crate::model::app_connector::PrincipalInfo>,

    /// Optional. Resource info of the connector.
    pub resource_info: std::option::Option<crate::model::ResourceInfo>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl AppConnector {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::AppConnector::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [create_time][crate::model::AppConnector::create_time].
    pub fn set_create_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [create_time][crate::model::AppConnector::create_time].
    pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [update_time][crate::model::AppConnector::update_time].
    pub fn set_update_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.update_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [update_time][crate::model::AppConnector::update_time].
    pub fn set_or_clear_update_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.update_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [labels][crate::model::AppConnector::labels].
    pub fn set_labels<T, K, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = (K, V)>,
        K: std::convert::Into<std::string::String>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
        self
    }

    /// Sets the value of [display_name][crate::model::AppConnector::display_name].
    pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.display_name = v.into();
        self
    }

    /// Sets the value of [uid][crate::model::AppConnector::uid].
    pub fn set_uid<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.uid = v.into();
        self
    }

    /// Sets the value of [state][crate::model::AppConnector::state].
    pub fn set_state<T: std::convert::Into<crate::model::app_connector::State>>(
        mut self,
        v: T,
    ) -> Self {
        self.state = v.into();
        self
    }

    /// Sets the value of [principal_info][crate::model::AppConnector::principal_info].
    pub fn set_principal_info<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::app_connector::PrincipalInfo>,
    {
        self.principal_info = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [principal_info][crate::model::AppConnector::principal_info].
    pub fn set_or_clear_principal_info<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::app_connector::PrincipalInfo>,
    {
        self.principal_info = v.map(|x| x.into());
        self
    }

    /// Sets the value of [resource_info][crate::model::AppConnector::resource_info].
    pub fn set_resource_info<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::ResourceInfo>,
    {
        self.resource_info = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [resource_info][crate::model::AppConnector::resource_info].
    pub fn set_or_clear_resource_info<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::ResourceInfo>,
    {
        self.resource_info = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for AppConnector {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.beyondcorp.appconnectors.v1.AppConnector"
    }
}

/// Defines additional types related to [AppConnector].
pub mod app_connector {
    #[allow(unused_imports)]
    use super::*;

    /// PrincipalInfo represents an Identity oneof.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct PrincipalInfo {
        pub r#type: std::option::Option<crate::model::app_connector::principal_info::Type>,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl PrincipalInfo {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [r#type][crate::model::app_connector::PrincipalInfo::type].
        ///
        /// Note that all the setters affecting `r#type` are mutually
        /// exclusive.
        pub fn set_type<
            T: std::convert::Into<
                    std::option::Option<crate::model::app_connector::principal_info::Type>,
                >,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.r#type = v.into();
            self
        }

        /// The value of [r#type][crate::model::app_connector::PrincipalInfo::r#type]
        /// if it holds a `ServiceAccount`, `None` if the field is not set or
        /// holds a different branch.
        pub fn service_account(
            &self,
        ) -> std::option::Option<
            &std::boxed::Box<crate::model::app_connector::principal_info::ServiceAccount>,
        > {
            #[allow(unreachable_patterns)]
            self.r#type.as_ref().and_then(|v| match v {
                crate::model::app_connector::principal_info::Type::ServiceAccount(v) => {
                    std::option::Option::Some(v)
                }
                _ => std::option::Option::None,
            })
        }

        /// Sets the value of [r#type][crate::model::app_connector::PrincipalInfo::r#type]
        /// to hold a `ServiceAccount`.
        ///
        /// Note that all the setters affecting `r#type` are
        /// mutually exclusive.
        pub fn set_service_account<
            T: std::convert::Into<
                    std::boxed::Box<crate::model::app_connector::principal_info::ServiceAccount>,
                >,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.r#type = std::option::Option::Some(
                crate::model::app_connector::principal_info::Type::ServiceAccount(v.into()),
            );
            self
        }
    }

    impl wkt::message::Message for PrincipalInfo {
        fn typename() -> &'static str {
            "type.googleapis.com/google.cloud.beyondcorp.appconnectors.v1.AppConnector.PrincipalInfo"
        }
    }

    /// Defines additional types related to [PrincipalInfo].
    pub mod principal_info {
        #[allow(unused_imports)]
        use super::*;

        /// ServiceAccount represents a GCP service account.
        #[derive(Clone, Default, PartialEq)]
        #[non_exhaustive]
        pub struct ServiceAccount {
            /// Email address of the service account.
            pub email: std::string::String,

            pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
        }

        impl ServiceAccount {
            pub fn new() -> Self {
                std::default::Default::default()
            }

            /// Sets the value of [email][crate::model::app_connector::principal_info::ServiceAccount::email].
            pub fn set_email<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
                self.email = v.into();
                self
            }
        }

        impl wkt::message::Message for ServiceAccount {
            fn typename() -> &'static str {
                "type.googleapis.com/google.cloud.beyondcorp.appconnectors.v1.AppConnector.PrincipalInfo.ServiceAccount"
            }
        }

        #[derive(Clone, Debug, PartialEq)]
        #[non_exhaustive]
        pub enum Type {
            /// A GCP service account.
            ServiceAccount(
                std::boxed::Box<crate::model::app_connector::principal_info::ServiceAccount>,
            ),
        }
    }

    /// Represents the different states of a AppConnector.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum State {
        /// Default value. This value is unused.
        Unspecified,
        /// AppConnector is being created.
        Creating,
        /// AppConnector has been created.
        Created,
        /// AppConnector's configuration is being updated.
        Updating,
        /// AppConnector is being deleted.
        Deleting,
        /// AppConnector is down and may be restored in the future.
        /// This happens when CCFE sends ProjectState = OFF.
        Down,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [State::value] or
        /// [State::name].
        UnknownValue(state::UnknownValue),
    }

    #[doc(hidden)]
    pub mod state {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl State {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::Creating => std::option::Option::Some(1),
                Self::Created => std::option::Option::Some(2),
                Self::Updating => std::option::Option::Some(3),
                Self::Deleting => std::option::Option::Some(4),
                Self::Down => std::option::Option::Some(5),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
                Self::Creating => std::option::Option::Some("CREATING"),
                Self::Created => std::option::Option::Some("CREATED"),
                Self::Updating => std::option::Option::Some("UPDATING"),
                Self::Deleting => std::option::Option::Some("DELETING"),
                Self::Down => std::option::Option::Some("DOWN"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for State {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for State {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for State {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::Creating,
                2 => Self::Created,
                3 => Self::Updating,
                4 => Self::Deleting,
                5 => Self::Down,
                _ => Self::UnknownValue(state::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for State {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "STATE_UNSPECIFIED" => Self::Unspecified,
                "CREATING" => Self::Creating,
                "CREATED" => Self::Created,
                "UPDATING" => Self::Updating,
                "DELETING" => Self::Deleting,
                "DOWN" => Self::Down,
                _ => Self::UnknownValue(state::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for State {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::Creating => serializer.serialize_i32(1),
                Self::Created => serializer.serialize_i32(2),
                Self::Updating => serializer.serialize_i32(3),
                Self::Deleting => serializer.serialize_i32(4),
                Self::Down => serializer.serialize_i32(5),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for State {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
                ".google.cloud.beyondcorp.appconnectors.v1.AppConnector.State",
            ))
        }
    }
}

/// Represents the metadata of the long-running operation.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct AppConnectorOperationMetadata {
    /// Output only. The time the operation was created.
    pub create_time: std::option::Option<wkt::Timestamp>,

    /// Output only. The time the operation finished running.
    pub end_time: std::option::Option<wkt::Timestamp>,

    /// Output only. Server-defined resource path for the target of the operation.
    pub target: std::string::String,

    /// Output only. Name of the verb executed by the operation.
    pub verb: std::string::String,

    /// Output only. Human-readable status of the operation, if any.
    pub status_message: std::string::String,

    /// Output only. Identifies whether the user has requested cancellation
    /// of the operation. Operations that have successfully been cancelled
    /// have [Operation.error][] value with a
    /// [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to
    /// `Code.CANCELLED`.
    ///
    /// [google.rpc.Status.code]: rpc::model::Status::code
    pub requested_cancellation: bool,

    /// Output only. API version used to start the operation.
    pub api_version: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl AppConnectorOperationMetadata {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [create_time][crate::model::AppConnectorOperationMetadata::create_time].
    pub fn set_create_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [create_time][crate::model::AppConnectorOperationMetadata::create_time].
    pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [end_time][crate::model::AppConnectorOperationMetadata::end_time].
    pub fn set_end_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.end_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [end_time][crate::model::AppConnectorOperationMetadata::end_time].
    pub fn set_or_clear_end_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.end_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [target][crate::model::AppConnectorOperationMetadata::target].
    pub fn set_target<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.target = v.into();
        self
    }

    /// Sets the value of [verb][crate::model::AppConnectorOperationMetadata::verb].
    pub fn set_verb<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.verb = v.into();
        self
    }

    /// Sets the value of [status_message][crate::model::AppConnectorOperationMetadata::status_message].
    pub fn set_status_message<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.status_message = v.into();
        self
    }

    /// Sets the value of [requested_cancellation][crate::model::AppConnectorOperationMetadata::requested_cancellation].
    pub fn set_requested_cancellation<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.requested_cancellation = v.into();
        self
    }

    /// Sets the value of [api_version][crate::model::AppConnectorOperationMetadata::api_version].
    pub fn set_api_version<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.api_version = v.into();
        self
    }
}

impl wkt::message::Message for AppConnectorOperationMetadata {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.beyondcorp.appconnectors.v1.AppConnectorOperationMetadata"
    }
}

/// ResourceInfo represents the information/status of an app connector resource.
/// Such as:
///
/// - remote_agent
///   - container
///     - runtime
///     - appgateway
///       - appconnector
///         - appconnection
///           - tunnel
///       - logagent
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ResourceInfo {
    /// Required. Unique Id for the resource.
    pub id: std::string::String,

    /// Overall health status. Overall status is derived based on the status of
    /// each sub level resources.
    pub status: crate::model::HealthStatus,

    /// Specific details for the resource. This is for internal use only.
    pub resource: std::option::Option<wkt::Any>,

    /// The timestamp to collect the info. It is suggested to be set by
    /// the topmost level resource only.
    pub time: std::option::Option<wkt::Timestamp>,

    /// List of Info for the sub level resources.
    pub sub: std::vec::Vec<crate::model::ResourceInfo>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ResourceInfo {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [id][crate::model::ResourceInfo::id].
    pub fn set_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.id = v.into();
        self
    }

    /// Sets the value of [status][crate::model::ResourceInfo::status].
    pub fn set_status<T: std::convert::Into<crate::model::HealthStatus>>(mut self, v: T) -> Self {
        self.status = v.into();
        self
    }

    /// Sets the value of [resource][crate::model::ResourceInfo::resource].
    pub fn set_resource<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Any>,
    {
        self.resource = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [resource][crate::model::ResourceInfo::resource].
    pub fn set_or_clear_resource<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Any>,
    {
        self.resource = v.map(|x| x.into());
        self
    }

    /// Sets the value of [time][crate::model::ResourceInfo::time].
    pub fn set_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [time][crate::model::ResourceInfo::time].
    pub fn set_or_clear_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [sub][crate::model::ResourceInfo::sub].
    pub fn set_sub<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::ResourceInfo>,
    {
        use std::iter::Iterator;
        self.sub = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for ResourceInfo {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.beyondcorp.appconnectors.v1.ResourceInfo"
    }
}

/// HealthStatus represents the health status.
///
/// # Working with unknown values
///
/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
/// additional enum variants at any time. Adding new variants is not considered
/// a breaking change. Applications should write their code in anticipation of:
///
/// - New values appearing in future releases of the client library, **and**
/// - New values received dynamically, without application changes.
///
/// Please consult the [Working with enums] section in the user guide for some
/// guidelines.
///
/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum HealthStatus {
    /// Health status is unknown: not initialized or failed to retrieve.
    Unspecified,
    /// The resource is healthy.
    Healthy,
    /// The resource is unhealthy.
    Unhealthy,
    /// The resource is unresponsive.
    Unresponsive,
    /// Some sub-resources are UNHEALTHY.
    Degraded,
    /// If set, the enum was initialized with an unknown value.
    ///
    /// Applications can examine the value using [HealthStatus::value] or
    /// [HealthStatus::name].
    UnknownValue(health_status::UnknownValue),
}

#[doc(hidden)]
pub mod health_status {
    #[allow(unused_imports)]
    use super::*;
    #[derive(Clone, Debug, PartialEq)]
    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}

impl HealthStatus {
    /// Gets the enum value.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the string representation of enums.
    pub fn value(&self) -> std::option::Option<i32> {
        match self {
            Self::Unspecified => std::option::Option::Some(0),
            Self::Healthy => std::option::Option::Some(1),
            Self::Unhealthy => std::option::Option::Some(2),
            Self::Unresponsive => std::option::Option::Some(3),
            Self::Degraded => std::option::Option::Some(4),
            Self::UnknownValue(u) => u.0.value(),
        }
    }

    /// Gets the enum value as a string.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the integer representation of enums.
    pub fn name(&self) -> std::option::Option<&str> {
        match self {
            Self::Unspecified => std::option::Option::Some("HEALTH_STATUS_UNSPECIFIED"),
            Self::Healthy => std::option::Option::Some("HEALTHY"),
            Self::Unhealthy => std::option::Option::Some("UNHEALTHY"),
            Self::Unresponsive => std::option::Option::Some("UNRESPONSIVE"),
            Self::Degraded => std::option::Option::Some("DEGRADED"),
            Self::UnknownValue(u) => u.0.name(),
        }
    }
}

impl std::default::Default for HealthStatus {
    fn default() -> Self {
        use std::convert::From;
        Self::from(0)
    }
}

impl std::fmt::Display for HealthStatus {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
        wkt::internal::display_enum(f, self.name(), self.value())
    }
}

impl std::convert::From<i32> for HealthStatus {
    fn from(value: i32) -> Self {
        match value {
            0 => Self::Unspecified,
            1 => Self::Healthy,
            2 => Self::Unhealthy,
            3 => Self::Unresponsive,
            4 => Self::Degraded,
            _ => Self::UnknownValue(health_status::UnknownValue(
                wkt::internal::UnknownEnumValue::Integer(value),
            )),
        }
    }
}

impl std::convert::From<&str> for HealthStatus {
    fn from(value: &str) -> Self {
        use std::string::ToString;
        match value {
            "HEALTH_STATUS_UNSPECIFIED" => Self::Unspecified,
            "HEALTHY" => Self::Healthy,
            "UNHEALTHY" => Self::Unhealthy,
            "UNRESPONSIVE" => Self::Unresponsive,
            "DEGRADED" => Self::Degraded,
            _ => Self::UnknownValue(health_status::UnknownValue(
                wkt::internal::UnknownEnumValue::String(value.to_string()),
            )),
        }
    }
}

impl serde::ser::Serialize for HealthStatus {
    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        match self {
            Self::Unspecified => serializer.serialize_i32(0),
            Self::Healthy => serializer.serialize_i32(1),
            Self::Unhealthy => serializer.serialize_i32(2),
            Self::Unresponsive => serializer.serialize_i32(3),
            Self::Degraded => serializer.serialize_i32(4),
            Self::UnknownValue(u) => u.0.serialize(serializer),
        }
    }
}

impl<'de> serde::de::Deserialize<'de> for HealthStatus {
    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        deserializer.deserialize_any(wkt::internal::EnumVisitor::<HealthStatus>::new(
            ".google.cloud.beyondcorp.appconnectors.v1.HealthStatus",
        ))
    }
}
